<template>
<!-- 暂时废弃 -->
  <div>
    <div class="listTop">
      <div>
        <span class="tit">歌曲列表</span>
        <span class="musicNum">{{ playlist.tracks.length }}首歌</span>
      </div>
      <p class="playNum">
        播放：<span>{{ playlist.playCount }}</span> 次
      </p>
    </div>
    <table class="musicTable">
      <thead>
        <tr>
          <th class="SpaceTab"><p></p></th>
          <th class="mucicTitTab"><p>歌曲标题</p></th>
          <th class="Duration"><p>时长</p></th>
          <th class="singer"><p>歌手</p></th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in playlist.tracks" :key="index">
          <th>
            <p class="SerialNumber">
              {{ index }} <span @click="PlayClick(item)"></span>
            </p>
          </th>
          <th>
            <router-link
              tag="p"
              :to="{ name: 'musicdetail', query: { id: item.id } }"
              class="musciItemColor"
            >
              {{ item.name }} <span>{{ item.alia[0] }}</span>
            </router-link>
          </th>
          <th class="operationHover">
            <p class="musicTime">05:00</p>
            <div class="operationBox">
              <span class="play" @click="pushMusicAction(item)"></span>
              <span class="Collection"></span>
              <span class="forward"></span>
              <span class="download"></span>
            </div>
          </th>
          <th>
            <p class="musciItemColor">{{ item.ar[0].name }}</p>
          </th>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  props: {
    playlist: {
      type: Object,
      default: {},
    },
  },
  methods: {
    ...mapActions("musicStore", ["unshiftMusic", "pushMusicAction"]),
    async PlayClick(item) {
      //直接点击播放当前音乐

      await this.unshiftMusic({ data: item, that: this });
      // this.$bus.$emit("playCurrentMusic");
    },
  },
};
</script>

<style lang="scss" scoped>
.listTop {
  display: flex;
  margin-top: 27px;
  justify-content: space-between;
  border-bottom: 2px solid #c20c0c;
  .tit {
    font-size: 20px;
    line-height: 28px;
  }
  .musicNum {
    margin: 9px 0 0 20px;
    color: #666;
    font-size: 12px;
  }
  .playNum {
    color: #666;
    font-size: 12px;
    margin-top: 8px;
    span {
      color: #c20c0c;
    }
  }
}
.musicTable {
  width: 100%;
  border: 1px solid #d9d9d9;
  border-collapse: collapse;
  thead {
    height: 38px;
    th {
      vertical-align: top;
      height: 38px;
      background: url("./../../assets/imges/iconTwo.png") 0 0;
      p {
        background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -56px;
      }
    }
    .SpaceTab {
      width: 74px;
      p {
        background-image: none;
      }
    }
    .Duration {
      width: 91px;
    }
    .singer {
      width: 26%;
    }
    p {
      height: 18px;
      line-height: 18px;
      padding: 8px 10px;
      color: #666;
      text-align: left;
    }
  }
  tbody {
    tr {
      th {
        p {
          padding: 6px 10px;
          line-height: 18px;
          text-align: left;
          font-size: 12px;
          color: #666;
          font-weight: normal;
        }
        .musciItemColor {
          color: #333;
          cursor: pointer;
        }
        .SerialNumber {
          display: flex;
          justify-content: space-between;
          align-items: center;
          span {
            width: 17px;
            height: 17px;
            display: inline-block;
            cursor: pointer;
            background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -103px;
          }
        }
        .operationBox {
          display: none;
          span {
            display: inline-block;
            width: 18px;
            height: 16px;
            vertical-align: middle;
            margin-left: 5px;
          }
          .play {
            width: 13px;
            height: 13px;
            background: url("./../../assets/imges/btnIconTwo.png") no-repeat 0 -700px;
          }
          .Collection {
            background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -174px;
          }
          .forward {
            background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -195px;
          }
          .download {
            background: url("./../../assets/imges/iconTwo.png") no-repeat -81px -174px;
          }
        }
        &.operationHover:hover {
          .musicTime {
            display: none;
          }
          .operationBox {
            display: block;
          }
        }
      }
      &:nth-of-type(odd) {
        background-color: #f7f7f7;
      }
    }
  }
}
</style>